$("#tbl_user").bootstrapTable({
    url:"tushu/jieyue",
    contentType:'application/x-www-form-urlencoded',
    method:'POST',
    toolbar:'#toolbar',
    sidePagination:'server',
    pageNumber:1,//当前页
    pageSize:5,//每页条数
    pageList:[5, 10, 15, 20,'ALL'],
    dataType:'json',//返回数据的类型
    cache:false,
    pagination:true,//使用分页
    showRefresh:true,//右上角刷新按钮
    showColumns:true,//右上角,列,列表
    queryParams:function(params){
        params["tu_name"] = $("#username").val();
        params["lx.lx_id"] = $("#roleCondition").val();
        console.log(params)
        return params;
    },
    classes:'table table-hover table-striped',
    columns:[{
        checkbox:true
    },{
        field:"ts_id",
        title:"主键",
        align:"center"
    },{
        field:"tu_name",
        title:"图书名称",
        align:"center"
    },{
        field:"jieyue",
        title:"借阅价格",
        align:"center"
    },{
        field:"chushou",
        title:"出售价格",
        align:"center"
    },{
        field:"posun",
        title:"破损量比",
        align:"center"
    },{
        field:"cishu",
        title:"借阅次数",
        align:"center"
    },{
        field:"lx.lx_name",
        title:"类型",
        align:"center"
    },{
        field:"chubanshe.cbs_name",
        title:"出版社名字",
        align:"center"
    },{
        field:"book_img",
        title:"图书图片",
        align:"center",
        formatter:function (value, row, index) {
            console.log("nuhbhubu"+row.book_img)
            return '<img src="'+row.book_img+'" width="80px" />';
        }
    },{
        field:'operation',
        title:'操作',
        align:'center',
        formatter:function (value,row,index) {
            var array = [
                '<a href="javascript:void(0)" onclick="borrow(\'图书借阅\',\'tushu/borrow?ts_id='+row.ts_id+'\')"><span>借阅</span></a>',
                ''
            ];
            return array.join('');
        }
    }]
});

function borrow(title,url){
     $('#myModal').find('.modal-title').empty().text(title);
     $('#myModal').find('.modal-body').empty().load(url);
     $('#myModal').modal('show');
}

//提交表单
function submitForm1(form) {
    var $form = $(form).parents("#myModal").find("#jyxx");
    var action = $($form).attr('action');
    // var str = new FormData($(form).get(0));
    //  var str = form.serialize();
    var jy_guihuan = $($form).find("#jy_guihuan").val();
    var dz_id = $($form).find("#dz_id").val();
    var ts_id = $($form).find("#ts_id").val();
    console.log(dz_id);
    console.log(jy_guihuan);
    var  data = {"jy_guihuan":jy_guihuan,"dz_id":dz_id,"ts_id":ts_id};

     $.post(action,data,function (data) {
         if(data.result){
                         swal("操作成功！",  "您完成了操作");
                         //隐藏模态框
                         $("#myModal").modal('hide');
                         //刷新表格
                         $("#tbl_user").bootstrapTable('refresh');

                     }
     },'json');

}
function setCondition(tbl) {
    $("#tbl_user").bootstrapTable('refresh');
}